package baseFx.common.services;

import baseFx.common.EventDispatcher;

import java.util.Map;

public interface ServiceContext extends AutoCloseable {
    EventDispatcher<ServiceObjectErrorArgs> eventError();

    EventDispatcher<ServiceObjectArgs> eventBefore();

    EventDispatcher<ServiceObjectArgs> eventAfter();

    Map<String, Object> getUserdata();

    void use(ServiceObject serviceObject, Object state);

    @Override
    void close();

    default void use(ServiceObject serviceObject) {
        use(serviceObject, null);
    }
}
